/**
 * ChaShaKu Data
 * @author Yusak Taniguchi
 */
Ext.app.Data = {
	POS: new Ext.data.JsonStore({
		autoLoad:true,
		url: 'config/pos.json',
		root: 'list',
		fields: ['item']
	}),
	Ctype: new Ext.data.JsonStore({
		autoLoad:true,
		url: 'config/ctype.json',
		root: 'list',
		fields: ['item']		
	}),
	Cform: new Ext.data.JsonStore({
		autoLoad:true,
		url: 'config/cform.json',
		root: 'list',
		fields: ['item']
	}),
	SentenceStore: {
		create: function(proxy_config,params){
			return new Ext.data.Store({
				proxy: new Ext.data.HttpProxy(proxy_config),		 
			    reader: new Ext.data.JsonReader({
					root: 'sentences',
					totalProperty: 'total',
					id: 'id'
				},Ext.app.Data.Record.Sentence),
				baseParams: params,
				sortInfo : {field: "center", direction: "ASC"},
				remoteSort: true
			});
		}
	},
	ListStore: {
		create: function(proxy_config,params){
			return new Ext.data.Store({
				proxy: new Ext.data.HttpProxy(proxy_config),		 
			    reader: new Ext.data.JsonReader({
					root: 'list',
					totalProperty: 'total'
				},Ext.app.Data.Record.ListContent),
				baseParams: params,
				sortInfo : {field: "count", direction: "DESC"},
				remoteSort: true
			});
		}
	},
	GroupingListStore:{
		create: function(proxy_config,params){
			return new Ext.data.GroupingStore({
				proxy: new Ext.data.HttpProxy(proxy_config),		 
			    reader: new Ext.data.JsonReader({
					root: 'list',
					totalProperty: 'total'
				},Ext.app.Data.Record.ListContent),
				baseParams: params,
				sortInfo : {field: "center", direction: "ASC"},
				groupField:'center',
				remoteSort: true
			});
		}
	},
	SequenceStore:{
		create: function(proxy_config,params,size){
			var words = []
			for (var i = 0; i < size; i++) {
				words.push({name: 'word' + i});
			}
			words.push({name: 'count',type: 'int'});
			var record = Ext.data.Record.create(words);
			return new Ext.data.Store({
				proxy: new Ext.data.HttpProxy(proxy_config),		 
			    reader: new Ext.data.JsonReader({
					root: 'list',
					totalProperty: 'total'
				},record),
				baseParams: params,
				sortInfo : {field: "count", direction: "DESC"},
				remoteSort: true
			});
		}
	},
	WordPropertyStore:{
		create: function(){
			return new Ext.data.Store({
				reader: new Ext.data.JsonReader({
					root: 'keywords'
				},Ext.app.Data.Record.Word)
			});
		}
	},
	Record: {
		Sentence: Ext.data.Record.create([
		    {name: 'id', type: 'int'},
		    {name: 'left_side'},
		    {name: 'center'},
		    {name: 'right_side'},
			{name: 'text'}
		]),
		ListContent: Ext.data.Record.create([
		    {name: 'count', type: 'int'},
		    {name: 'left_side'},
		    {name: 'center'},
		    {name: 'right_side'}
		]),
		Word: Ext.data.Record.create([
			{name: 'surface', type: 'string' },
			{name: 'reading', type: 'string' },
			{name: 'pronunciation', type: 'string' },
			{name: 'part_of_speech', type: 'string' },
			{name: 'ctype', type: 'string' },
			{name: 'cform', type: 'string' },
			{name: 'basetype_surface', type: 'string' },
			{name: 'basetype_reading', type: 'string' },
			{name: 'basetype_pronunciation', type: 'string' },
			{name: 'center_word', type: 'boolean'},
			{name: 'interval',type: 'string'}
		])
	}
};

